package com.ash.servlet;

import com.ash.entity.Constant;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author : Chen Chao
 * @encoding : UTF-8
 * @date : 2020/12/26 12:24
 * @file : test06.${PACKAGE_NAME}.${NAME}.java
 * @software : IntelliJ IDEA
 * @since : 1.8
 */
@WebServlet("/LogoutServlet")
public class LogoutServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("来到logout");
        resp.getWriter().println("来到logout");
        /*清除USER_SESSION并重定向到login.jsp*/
        req.getSession().removeAttribute(Constant.USER_SESSION);
        resp.sendRedirect("login.jsp");
    }
}
